package com.school.service.impl;

import com.school.entity.ClassEntity;
import com.school.repository.ClassRepository;
import com.school.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class ClassServiceImpl implements ClassService {
    @Autowired
    private ClassRepository classRepository;

    @Override
    public List<ClassEntity> findAll() {
        return classRepository.findAll();
    }

    @Override
    public Optional<ClassEntity> findById(Long id) {
        return classRepository.findById(id);
    }

    @Override
    public Optional<ClassEntity> findByName(String name) {
        return classRepository.findByName(name);
    }

    @Override
    public ClassEntity save(ClassEntity classEntity) {
        return classRepository.save(classEntity);
    }

    @Override
    public void deleteById(Long id) {
        classRepository.deleteById(id);
    }
}
